package com.taichuan.selfcheck.ui.fragment;


import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.taichuan.selfcheck.R;
import com.taichuan.selfcheck.mvp.presenter.EmptyPresenter;
import com.taichuan.selfcheck.mvp.viewinterface.EmptyInterface;
import com.taichuan.selfcheck.ui.fragment.base.AppBaseFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 屏幕素质测试 选择界面
 */
public class SelectScreenTestFragment extends AppBaseFragment<EmptyInterface, EmptyPresenter> implements EmptyInterface {

    @BindView(R.id.screen_color_test)
    Button colorTestBtn;
    @BindView(R.id.screen_gray_scale_test)
    Button grayScaleTest;


    @Override
    protected boolean isAllowAutoFinishFragment() {
        return false;
    }

    @Override
    public void doOnAutoFinishFragment() {
        operateFragmentManagerBack();
    }

    @Override
    protected void getBundleValues(Bundle bundle) {

    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        switch (event.getKeyCode()){
            case KeyEvent.KEYCODE_1:
                colorTestBtn.performClick();
                break;
            case KeyEvent.KEYCODE_2:
                grayScaleTest.performClick();
                break;
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    protected int setContentViewId() {
        return R.layout.fragment_select_screen_test;
    }

    @Override
    protected void initView(View view, Bundle bundle) {

    }

    @Override
    protected EmptyPresenter createPresenter() {
        return new EmptyPresenter();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @OnClick({R.id.screen_color_test, R.id.screen_gray_scale_test})
    @Override
    protected void onXmlClick(View v) {
        super.onXmlClick(v);
        switch (v.getId()){
            case R.id.screen_color_test:{
                getActivityBaseFragmentManager().replace(new ScreenColorTestFragment());
                break;
            }
            case R.id.screen_gray_scale_test:{
                getActivityBaseFragmentManager().replace(new ScreenGrayScaleTestFragment());
                break;
            }
        }
    }
}
